package net.fdukedom.epicurus.service.interaction;

import org.jdom.Document;
import org.jdom.Element;

public class IdentificationRequestWriter extends IdentificationRequest {

	public IdentificationRequestWriter(String idValue) {
		this.idValue = idValue;
		createDocument();
	}

	@Override
	protected void createDocument() {
		Element rootElement = new Element(REQUEST);

		Element idElem = new Element(ID);
		idElem.setText(idValue);
		rootElement.addContent(idElem);
		
		Element parametersElem = new Element(PARAMETERS);
		rootElement.addContent(parametersElem);

		doc = new Document();
		doc.setRootElement(rootElement);
	}

	/**
	 * Sets email
	 * 
	 * @value email
	 */
	public void setEmail(String value) {
		updateRootChildElement(EMAIL, value);
	}

	/**
	 * Sets user password
	 * 
	 * @value user password
	 */
	public void setPassword(String value) {
		updateRootChildElement(PASSWORD, value);
	}
	
	/**
	 * Sets content of parameter element
	 * 
	 * @value user password
	 */
	public void setTextParameter(String value) {
		updateRootChildElement(PARAMETERS, value);
	}
	
	/**
	 * Sets result element
	 * 
	 * @param element
	 *            result element
	 */
	public void addParameter(Element element) {
		setElement(REQUEST_PREFIX + PARAMETERS, element);
	}
}
